package com.xh.bussiness.tiku.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xh.bussiness.tiku.dao.QuestionSourceMapper;
import com.xh.bussiness.tiku.model.QuestionSource;
import com.xh.bussiness.tiku.service.IQuestionSourceService;
import com.xh.core.service.impl.BaseServiceImpl;
import com.xh.core.util.StringUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class QuestionSourceServiceImpl extends BaseServiceImpl<QuestionSourceMapper, QuestionSource> implements IQuestionSourceService {


    @Override
    public List<QuestionSource> queryQuestionSourceByQuestionId(String questionId) {
        if (StringUtils.isEmpty(questionId)) {
            return new ArrayList<>();
        }
        QueryWrapper<QuestionSource> qw = new QueryWrapper<>();
        qw.eq("question_id", questionId);
        qw.orderByAsc("order_no");
        return this.dao.selectList(qw);
    }

    /**
     * 查询详细来源
     * @author 赵文博
     * @date 2021/4/16 11:04
     * @param questionId
     * @return java.util.List<com.xh.bussiness.tiku.model.QuestionSource>
     **/
    @Override
    public List<QuestionSource> queryQuestionDetailSourceByQuestionId(String questionId) {
        return this.dao.queryQuestionDetailSourceByQuestionId(questionId);
    }

    @Override
    public void deleteQuestionSourceByQuestionId(String questionId) {
        this.dao.deleteByQuestionId(questionId);
    }

}
